package com.zr.ssm.mapper;

import com.zr.ssm.pojo.Artical;
import com.zr.ssm.pojo.ArticalSql;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

public interface ArticalMapper {

    @Insert("insert into ev_articles values (null, #{title}, #{content},#{cover_img},#{pub_date}," +
            "#{state},0,#{cate_id},#{author_id})")
    int insert(Artical artical);

//    @Select("select * from ev_articles")
    @SelectProvider(value = ArticalSql.class, method = "getDynamicSql")
    List<Artical> selectAll(Artical artical);

    @Delete("delete from ev_articles where id = #{id}")
    int deletById(Integer id);

    @Select("select * from ev_articles where id = #{id}")
    Artical selectById(Integer id);
}
